#ifndef ABSTRACTSTORAGE_H
#define ABSTRACTSTORAGE_H

#include <QObject>

class QXmlStreamReader;
class QXmlStreamWriter;
class AbstractContainer;


class AbstractStorage : public QObject
{
    Q_OBJECT
public:
    AbstractStorage(const QString &name = "unknownObject");
    AbstractStorage(AbstractStorage &stor);
    AbstractStorage(AbstractStorage *stor);
    virtual ~AbstractStorage();

    enum Type {
        database,
        table
    };

    virtual bool readFromXml(QXmlStreamReader* pXml);
    virtual bool writeToXml(QXmlStreamWriter* pXml);

    static AbstractStorage* crateStorage(Type id);

    AbstractContainer *appendContainer(const QString &name);
    QList<AbstractContainer*> *containers() { return &m_containers; }
    AbstractContainer* containerByName( const QString &name);

private:
    void initProperties();

protected:
    void copyDynamicPoperties(const QObject *source);
    void writeDynamicPropsToXml(QXmlStreamWriter *pXml);
    void readDynamicPropsFromXml(QXmlStreamReader* pXml);

    QList<AbstractContainer*> m_containers;
};

#endif // ABSTRACTSTORAGE_H
